$(function () {
    $(document).ready(function() {
        Highcharts.visualize = function(table, options) {
            // the categories
            options.xAxis.categories = [];
            $('tbody th', table).each( function(i) {
                options.xAxis.categories.push(this.innerHTML);
            });
    
            // the data series
            options.series = [];
            $('tr', table).each( function(i) {
                var tr = this;
                $('th, td', tr).each( function(j) {
                    if (j > 0) { // skip first column
                        if (i == 0) { // get the name and init the series
                            options.series[j - 1] = {
                                name: this.innerHTML,
                                data: []
                            };
                        } else { // add values
                            options.series[j - 1].data.push(parseFloat(this.innerHTML));
                        }
                    }
                });
            });
    
            var chart = new Highcharts.Chart(options);
          
       }

        var table = document.getElementById('datatable1'),
        options = {
            chart: {
                renderTo: 'table',
                type: 'column'
            },
            title: {
                text: 'Consumo dos Clientes'
            },
            xAxis: {
            },
            yAxis: {
                title: {
                    text: 'Valor(R$)'
                }
            }
         };

       var table2 = document.getElementById('datatable2'),
        options2 = {
            chart: {
                renderTo: 'table2',
                type: 'column'
            },
            title: {
                text: 'Valor Custo x Valor Vendas'
            },
            xAxis: {
            },
            yAxis: {
                title: {
                    text: 'Valor(R$)'
                }
            }
            
        };
         var table3 = document.getElementById('datatable3'),
          options3 = {
            chart: {
                renderTo: 'table3',
                type: 'column'
            },
            title: {
                text: 'Produtos mais Consumidos'
            },
            xAxis: {
            },
            yAxis: {
                title: {
                    text: 'Unidades'
                }
            }
            
        };






     var highchartsOptions = Highcharts.setOptions(Highcharts.theme);

     Highcharts.visualize(table, options);
     Highcharts.visualize(table2, options2);
     Highcharts.visualize(table3, options3);
 
    });

});
